package com.ruoyi.storage.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.storage.domain.ExitDetail;
import com.ruoyi.storage.service.IExitDetailService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 出库详情Controller
 * 
 * @author 庞一恺
 * @date 2025-01-23
 */
@RestController
@RequestMapping("/storage/exitDetail")
public class ExitDetailController extends BaseController
{
    @Autowired
    private IExitDetailService exitDetailService;

    /**
     * 查询出库详情列表
     */
    @PreAuthorize("@ss.hasPermi('storage:exitDetail:list')")
    @GetMapping("/list")
    public TableDataInfo list(ExitDetail exitDetail)
    {
        startPage();
        List<ExitDetail> list = exitDetailService.selectExitDetailList(exitDetail);
        return getDataTable(list);
    }

    /**
     * 导出出库详情列表
     */
    @PreAuthorize("@ss.hasPermi('storage:exitDetail:export')")
    @Log(title = "出库详情", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ExitDetail exitDetail)
    {
        List<ExitDetail> list = exitDetailService.selectExitDetailList(exitDetail);
        ExcelUtil<ExitDetail> util = new ExcelUtil<ExitDetail>(ExitDetail.class);
        util.exportExcel(response, list, "出库详情数据");
    }

    /**
     * 获取出库详情详细信息
     */
    @PreAuthorize("@ss.hasPermi('storage:exitDetail:query')")
    @GetMapping(value = "/{itemId}")
    public AjaxResult getInfo(@PathVariable("itemId") String itemId)
    {
        return success(exitDetailService.selectExitDetailByItemId(itemId));
    }

    /**
     * 新增出库详情
     */
    @PreAuthorize("@ss.hasPermi('storage:exitDetail:add')")
    @Log(title = "出库详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ExitDetail exitDetail)
    {
        return toAjax(exitDetailService.insertExitDetail(exitDetail));
    }

    /**
     * 修改出库详情
     */
    @PreAuthorize("@ss.hasPermi('storage:exitDetail:edit')")
    @Log(title = "出库详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ExitDetail exitDetail)
    {
        return toAjax(exitDetailService.updateExitDetail(exitDetail));
    }

    /**
     * 删除出库详情
     */
    @PreAuthorize("@ss.hasPermi('storage:exitDetail:remove')")
    @Log(title = "出库详情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{itemIds}")
    public AjaxResult remove(@PathVariable String[] itemIds)
    {
        return toAjax(exitDetailService.deleteExitDetailByItemIds(itemIds));
    }
}
